#include "doctorwindow.h"
#include "ui_doctorwindow.h"

DoctorWindow::DoctorWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::DoctorWindow)
{
    ui->setupUi(this);
    //this->setWindowTitle("医生窗口");

    chat.setCurrentMode(doctor);

    //状态栏实时显示当前显示患者
    currentPatient=new QLabel("当前未选择患者",this);
    this->statusBar()->addWidget(currentPatient);

    ui->stackedWidget->addWidget(&doctorSelect);
    ui->stackedWidget->addWidget(&information);
    ui->stackedWidget->addWidget(&diagnosis);
    ui->stackedWidget->addWidget(&chat);

    btnGroup.addButton(ui->toolButton_select, 0);
    btnGroup.addButton(ui->toolButton_info, 1);
    btnGroup.addButton(ui->toolButton_query, 2);
    btnGroup.addButton(ui->toolButton_chat, 3);
    connect(&btnGroup, QOverload<int>::of(&QButtonGroup::buttonClicked), ui->stackedWidget, &QStackedWidget::setCurrentIndex);

    connect(&doctorSelect,&DoctorSelect::select,[=](int selectId){
        this->selectId=selectId;
        //更改状态栏
        currentPatient->setText("当前患者：xxx");
        //选择患者后，解锁相应功能
        ui->toolButton_info->setEnabled(true);
        ui->toolButton_query->setEnabled(true);
        ui->toolButton_chat->setEnabled(true);
    });

    btnGroup.button(0)->setChecked(true);
    ui->stackedWidget->setCurrentIndex(0);
}

DoctorWindow::~DoctorWindow()
{
    delete ui;
}

void DoctorWindow::setSelectId(int selectId)
{
    this->selectId=selectId;
}
